#ifndef CHONEYCOMBPICKCOLOR_H
#define CHONEYCOMBPICKCOLOR_H

#include <QWidget>
#include <QPainterPath>
#include <QPainter>
class CHoneycombPickColor : public QWidget
{
    Q_OBJECT
public:
    explicit CHoneycombPickColor(QWidget *parent = nullptr);

    void setHexagonRad(int nHexagonRad); //设置六边形格子半径
    void setHexagonRadRange(int nMin,int nMax);
    void setHexagonRadStep(int nStep);
signals:
    void sigSelected(QColor color);
protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;
    void paintEvent(QPaintEvent *event) override;

    void drawHexagon(QPainter *painter, QPoint pt, int nRad); //画六边形
    QPainterPath hexagonPath(int nRad,QPoint pt = QPoint(0,0),int nRotate = 0);     //构造六边形
    void setHexagonBrush(QPainter &painter, int nAngle, qreal dRadScale); //半径比
private:
    QPoint m_ptClicked;
    QColor m_colorSelected;
    int m_nHexagonRad = 20; //六边形格子外切圆半径

    //格子大小限制
    int m_nHexagonMaxRad = 100;
    int m_nHexagonMinRad = 10;
    int m_nHexagonStepRad = 5;  //滚动鼠标滑轮 格子变化的步长

    bool m_bIsPressed = false;  //标记鼠标是否按下
};

#endif // CHONEYCOMBPICKCOLOR_H
